home *** CD-ROM | disk | FTP | other *** search
- /*
- * Utilities Module
- *
- * Jwahar Bammi
- * usenet: cwruecmp!bammi@decvax.UUCP
- * csnet: bammi@cwru.edu
- * arpa: bammi@cwru.edu
- * CompuServe: 71515,155
- */
-
-
- #include "zmdm.h"
-
- #ifndef Vsync /* Atari forgot these in osbind.h */
- #define Vsync() xbios(37)
- #endif
-
- #define goto(r,c) EscSeq('Y');Bconout(2, r+040);Bconout(2, c+040)
-
- /* External Variables */
- extern int *aline_addr; /* Ptr to base of Aline variables */
- extern long *ms_ptr; /* pointer to my screen memory aligned to a 256
- byte boundary */
-
- /* Globals */
- static char *hs_ptr; /* pointer to his screen memory */
- static int x_saved, y_saved; /* Saved cursor position */
-
- /*
- * my_screen() - Start using my screen memory
- * for all output.
- *
- */
- void my_screen()
- {
- /* The cursor position has been saved prior to calling this routine */
- x_saved = aline_addr[-14];
- y_saved = aline_addr[-13];
-
- /* save his screen memory pointer */
- hs_ptr = (char *)Logbase();
-
- /* switch to my display memory */
- Setscreen(ms_ptr, ms_ptr, -1);
- }
-
-
- void his_screen()
- {
- /* switch to his Screen memory, wait for a Vblank, so
- * that the Logical Loc == Physical Loc, then pop saved
- * cursor */
- Setscreen(hs_ptr, hs_ptr, -1);
- Vsync();
- Vsync(); /* starts happening at the last one */
- goto(y_saved, x_saved);
-
- }
-
- /*
- * hit_key() - wait for the user to hit a key
- *
- */
- void hit_key()
- {
- Bconws("\r\n");
- EscSeq('p');
- Bconws("Hit Any Key To Continue .....");
- EscSeq('q');
- Bconin(2);
- Bconws("\r\n");
- }
-
-
- /*
- * find the size of a file given its name
- */
- long filesize(name)
- register char *name;
- {
- extern struct stat statbuf;
-
- if(Fsfirst(name,(int)(0x01 | 0x020)) != 0)
- {
- return 0L;
-
- }
-
- return statbuf.st_size;
- }
-
-
- /*
- * Write a string to console
- */
- Bconws(s)
- register char *s;
- {
- while(*s)
- Bconout(2, *s++);
- }
-
- #ifndef MWC
-
- /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
- /* */
- /* ALCYON C dependant, this routine must return the base address of */
- /* of the linea variable block */
- /* */
- /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
-
- /*
- * return the base address of the line A variables
- */
- int *aaddress()
- {
- asm("dc.w $A000"); /* Line A trap - 0000 is init aline */
- /* d0 and a0 now contain the address */
- /* so we can just return and the result
- * will be valid
- */
- }
-
-
- /*
- * Make hi rez screen bios handle 50 lines of 8x8 characters
- *
- * Adapted to C use from origonal asm posting
- *
- */
- hi50()
- {
- /* Switch to 50 lines display */
-
- asm(".dc.w $a000"); /* get the important pointers */
-
- asm("move.l 04(a1),a1"); /* a1 -> 8x8 font header */
-
- asm("move.l 72(a1),-$0A(a0)"); /* v_off_ad <- 8x8 offset table addr */
- asm("move.l 76(a1),-$16(a0)"); /* v_fnt_ad <- 8x8 font data addr */
-
- asm("move.w #008,-$2E(a0)"); /* v_cel_ht <- 8 8x8 cell height */
- asm("move.w #049,-$2A(a0)"); /* v_cel_my <- 49 maximum cell "Y" */
- asm("move.w #640,-$28(a0)"); /* v_cel_wr <- 640 offset to cell Y+1 */
-
- }
-
- /*
- * Make hi rez screen bios handle 25 lines of 8x16 characters
- *
- */
- hi25()
- {
-
- /* Switch to 25 lines display */
-
-
- asm(".dc.w $a000"); /* get the important pointers */
-
- asm("move.l 08(a1),a1"); /* a1 -> 8x16 font header */
-
- asm("move.l 72(a1),-$0A(a0)"); /* v_off_ad <- 8x16 offset table addr */
- asm("move.l 76(a1),-$16(a0)"); /* v_fnt_ad <- 8x16 font data addr */
-
- asm("move.w #0016,-$2E(a0)"); /* v_cel_ht <- 16 8x16 cell height */
- asm("move.w #0024,-$2A(a0)"); /* v_cel_my <- 24 maximum cell "Y" */
- asm("move.w #1280,-$28(a0)"); /* v_cel_wr <- 1280 vertical byte offset */
- }
-
- #else
-
- /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
- /* */
- /* MWC dependant, this routine must return the base address of */
- /* of the linea variable block */
- /* */
- /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
- #include <linea.h>
- /*
- * return the base address of the line A variables
- */
-
- int *aaddress()
- {
- linea0(); /* Init LineA - dumps returned values into la_init */
- return (int *)(la_init.li_a0); /* Return address of Parameter Block */
- }
-
- /* Mark Williams C */
- /* See file hi5025.s */
- /* for functions hi50() */
- /* and hi25() */
- #endif /* MWC */
-